home *** CD-ROM | disk | FTP | other *** search
/ American Osteopathic Ass…tion Yearbook 2005 & 2006 / American Osteopathic Association Yearbook 2005 & 2006.iso / pc / server / mmserv.exe / glob.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2004-07-21  |  1.8 KB  |  67 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.3)
  3.  
  4. import os
  5. import fnmatch
  6. import re
  7. __all__ = [
  8.     'glob']
  9.  
  10. def glob(pathname):
  11.     if not has_magic(pathname):
  12.         if os.path.exists(pathname):
  13.             return [
  14.                 pathname]
  15.         else:
  16.             return []
  17.     
  18.     (dirname, basename) = os.path.split(pathname)
  19.     if not dirname:
  20.         return glob1(os.curdir, basename)
  21.     elif has_magic(dirname):
  22.         list = glob(dirname)
  23.     else:
  24.         list = [
  25.             dirname]
  26.     if not has_magic(basename):
  27.         result = []
  28.         for dirname in list:
  29.             if basename or os.path.isdir(dirname):
  30.                 name = os.path.join(dirname, basename)
  31.                 if os.path.exists(name):
  32.                     result.append(name)
  33.                 
  34.             os.path.exists(name)
  35.         
  36.     else:
  37.         result = []
  38.         for dirname in list:
  39.             sublist = glob1(dirname, basename)
  40.             for name in sublist:
  41.                 result.append(os.path.join(dirname, name))
  42.             
  43.         
  44.     return result
  45.  
  46.  
  47. def glob1(dirname, pattern):
  48.     if not dirname:
  49.         dirname = os.curdir
  50.     
  51.     
  52.     try:
  53.         names = os.listdir(dirname)
  54.     except os.error:
  55.         return []
  56.  
  57.     if pattern[0] != '.':
  58.         names = filter((lambda x: x[0] != '.'), names)
  59.     
  60.     return fnmatch.filter(names, pattern)
  61.  
  62. magic_check = re.compile('[*?[]')
  63.  
  64. def has_magic(s):
  65.     return magic_check.search(s) is not None
  66.  
  67.